
import Vue from 'vue'
import axios from 'axios'
//import echarts from 'echarts'

export const publicPath = process.env.VUE_APP_PUBLIC_PATH

/***
 * 将时间戳转成日期时间
 *
 * params:time（时间戳）
 */
 export function formatTime(format,number) {
	var formateArr  = ['Y','M','D','h','m','s'];
	var returnArr   = [];

	var date = new Date(number);
	returnArr.push(date.getFullYear());
	returnArr.push(formatNumber(date.getMonth() + 1));
	returnArr.push(formatNumber(date.getDate()));

	returnArr.push(formatNumber(date.getHours()));
	returnArr.push(formatNumber(date.getMinutes()));
	returnArr.push(formatNumber(date.getSeconds()));
	for (var i in returnArr)
	{
		format = format.replace(formateArr[i], returnArr[i]);
	}
	return format;
}

// 等级换风速
export function levelToSpeed(level) {
	var windSpeed = '0.0-0.2m/s';
	if (level == 'A'){
		windSpeed = '0.0-0.2m/s'
	}else if (level == 'B'){
		windSpeed = '0.3-1.5m/s'
	}else if (level == 'C'){
		windSpeed = '1.6-3.3m/s'
	}else if (level == 'D'){
		windSpeed = '3.4-5.4m/s'
	}else if (level == 'E'){
		windSpeed = '5.5-5.9m/s'
	}else if (level == 'F'){
		windSpeed = '8.0-10.7m/s'
	}else if (level == 'G'){
		windSpeed = '10.8-13.8m/s'
	}else if (level == 'H'){
		windSpeed = '13.9-17.1m/s'
	}else if (level == 'I'){
		windSpeed = '17.2-20.7m/s'
	}else if (level == 'J'){
		windSpeed = '20.8-24.4m/s'
	}else if (level == 'K'){
		windSpeed = '24.5-28.4m/s'
	}else if (level == 'L'){
		windSpeed = '28.5-32.6m/s'
	}else if (level == 'M'){
		windSpeed = '32.7-36.9m/s'
	}else if (level == 'N'){
		windSpeed = '37.0-41.4m/s'
	}else if (level == 'O'){
		windSpeed = '41.5-46.1m/s'
	}else if (level == 'P'){
		windSpeed = '46.2-50.9m/s'
	}else if (level == 'Q'){
		windSpeed = '51.0-56.0m/s'
	}else if (level == 'R'){
		windSpeed = '56.1-61.2m/s'
	}else if (level == 'S'){
		windSpeed = '61.3m-69.4/s'
	}else{
		windSpeed = '>=69.4/s'
	}
	
	return windSpeed;
}

// export function initEchartComponent(domEle, option) {
// 	if(!domEle){
// 	  console.error('DOM元素不存在')
// 	  return
// 	}
// 	const ele = echarts.init(domEle)
// 	ele.setOption(option,true)
// 	return ele
//   }
//数据转化
function formatNumber(n) {
	n = n.toString()
	return n[1] ? n : '0' + n
}
export const util = {

}

// 名词转化
export function termChange(term){
	let result = ''
	if (term == 'axleTwo'){
		result = '2轴车'
	}else if (term == 'axleThree'){
		result = '3轴车'
	}else if (term == 'axleFour'){
		result = '4轴车'
	}else if (term == 'axleFive'){
		result = '5轴车'
	}else if (term == 'axleSix'){
		result = '6轴车'
	}else if (term == 'getAxleSeven'){
		result = '7轴车'
	}else if (term == 'lte4500'){
		result = '<4.5t'
	}else if (term == 'lte16000'){
		result = '4.5-16t'
	}else if (term == 'lte25000'){
		result = '16-25t'
	}else if (term == 'lte31000'){
		result = '25-31t'
	}else if (term == 'lte49000'){
		result = '31-49t'
	}else if (term == 'lte62000'){
		result = '49-62t'
	}else if (term == 'gt62000'){
		result = '>62t'
	}else if (term == 'lte60'){
		result = '<60'
	}else if (term == 'lte80'){
		result = '60-80'
	}else if (term == 'lte90'){
		result = '80-90'
	}else if (term == 'lte100'){
		result = '90-100'
	}else if (term == 'lte110'){
		result = '100-110'
	}else if (term == 'lte120'){
		result = '110-120'
	}else if (term == 'gt120'){
		result = '>120'
	}else{

	}
	return result;

}

// 数组去重
export function unique(arr) {
    if (!Array.isArray(arr)) {
        console.log('type error!')
        return
    }
    var array = [];
    for (var i = 0; i < arr.length; i++) {
        if (array .indexOf(arr[i]) === -1) {
            array .push(arr[i])
        }
    }
    return array;
}